﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using MapCop.Test;
using MapCop.Test.Helpers;

namespace MapCop.Test.Rules
{
    [TestFixture]
    public class LabelLinksMapRuleTest : IDisposable
    {

        private Helpers.MapCopViewTester testView;
        private MapCop.MapCopPresenter presenter;
        TestFile simpleMap;
        string mapFilename = "MapCopPresenterTestTestMap.btm";


        public LabelLinksMapRuleTest()
        {
            simpleMap = new TestFile(mapFilename, 
                "MapCop.Test.TestData.SimpleMap.btm");
        }

        [SetUp]
        public void Setup()
        {
            testView = new Helpers.MapCopViewTester();
            presenter = new MapCopPresenter(testView);
        }

        [TearDown]
        public void TearDown()
        {
            testView = null;
            presenter = null;
        }


        [Test]
        public void ErrorsReturned()
        {
            testView.Filename = mapFilename;
            presenter.AnalyzeMap();
            List<MapError> errList = testView.Errors;

            bool foundSpecificError = false;
            foreach (MapError loopError in errList)
            {
                // Modify this line to look for the title of the new error.
                foundSpecificError |= loopError.Title == "Label all Links between functoids";
            }

            Assert.IsTrue(foundSpecificError, "Error was not found");
            Assert.IsNotNull(testView.Rules, "Rules List Not Null");
            Assert.Greater(testView.Rules.Count, 0, "Proper Rules Count");
            Assert.IsNotNull(errList, "Error List Not Null");
            Assert.Greater(errList.Count, 0, "Proper Error Count");
        }

        #region IDisposable Members

        public void Dispose()
        {
            simpleMap.Dispose();
        }

        #endregion
    }
}
